<?php 
	class WS_AnnouncementMod {
		
		private $_DB;
		
		public function __construct() {

			$this->_DB 	= new ConfigDB();

		}
		
		public function insertAnnouncementActivities($strArray) {
			
			$announce_title = escapestring($strArray['announce_title']);
			$announce_desc 	= escapestring($strArray['announce_desc']);
			$announce_li 	= escapestring($strArray['announce_li']);
			$dept_idFK 		= escapestring($strArray['dept_idFK']);
			$academic 		= escapestring($strArray['academic']);
			
			$academicVal = ( $academic == 1)? 1 : 0;
			
			$this->_DB->queryDB("INSERT INTO `tbl_announcement` (`announce_title`, `announce_desc`, `announe_li`, `dept_idFK`, `advising`) VALUES ('" . $announce_title . "', '" . $announce_desc . "', '" . $announce_li . "', '" . $dept_idFK . "', '" . $academicVal . "')");

		}
		
		public function updateAnnouncementActivities($strArray, $strID) {
			
			$announce_title = escapestring($strArray['announce_title']);
			$announce_desc 	= escapestring($strArray['announce_desc']);
			$announce_li 	= escapestring($strArray['announce_li']);
			$strID 			= escapestring($strID);
			
			$this->_DB->queryDB("UPDATE `tbl_announcement` SET `announce_title` = '" . $announce_title 	. "',
															   `announce_desc` 	= '" . $announce_desc 	. "',
															   `announe_li` 	= '" . $announce_li . "'
														 WHERE `announce_idPK` = '" . $strID . "'");

		}
		
		public function deleteAnnouncement($strID) {
			
			$strID = escapestring($strID);
			
			$this->_DB->queryDB("UPDATE `tbl_announcement` SET `is_deleted` = 'Y' WHERE `announce_idPK` = '" . $strID . "'");

		}
		
		public function getListAnnouncement($strDeptID, $strAdvising) {
			
			$strDeptID 	 = escapestring($strDeptID);
			$strAdvising = escapestring($strAdvising);
			
			return $this->_DB->selectDB("SELECT `announce_idPK`, `announce_title`, `announce_desc`, `announe_li`, `is_deleted` FROM `tbl_announcement` WHERE `dept_idFK` = '" . $strDeptID . "' AND `advising` = '" . $strAdvising . "' ORDER BY `announce_idPK` DESC");

		}
		
		public function getAllDeptAnnouncement($strDeptID) {
			
			$strDeptID 	 = escapestring($strDeptID);
			
			return $this->_DB->selectDB("SELECT `announce_idPK`, `announce_title`, `announce_desc`, `announe_li`, `is_deleted`, `timestamp` FROM `tbl_announcement` WHERE `dept_idFK` IN ('" . $strDeptID . "', '0') ORDER BY `dept_idFK`, `announce_idPK` DESC");

		}
		
		public function getAnnouncement($strAnnounceID) {
			
			$strAnnounceID = escapestring($strAnnounceID);
			
			return $this->_DB->selectDB2("SELECT `announce_idPK`, `announce_title`, `advising`, `announce_desc`, `announe_li`, `timestamp` FROM `tbl_announcement` WHERE `announce_idPK` = '" . $strAnnounceID . "'");

		}
		
	}
?>